package com.admin.action;

import com.admin.bean.ShieldWord;
import com.admin.service.ShieldWordService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * 屏蔽词管理
 *
 * @author:HingLo
 * @create 2017-09-12 10:53
 **/
@Controller
@RequestMapping("/ShieldWordAction/admin/")
public class ShieldWordAction {
    private static Logger logger = Logger.getLogger(ShieldWordAction.class);
    @Autowired
    private ShieldWordService shieldWordService;

    /**
     * 进入到屏蔽词管理
     *
     * @param request
     * @return
     */
    @GetMapping("inputShieldWord")
    public String inputShieldWordAction(HttpServletRequest request) {
        ShieldWord shieldWord = shieldWordService.findShieldWordService();
        request.setAttribute("data", shieldWord);
        return "/WEB-INF/admin/version/shieldWord";
    }

    @RequestMapping("submit")
    public String changeShieldWordAction(ShieldWord shieldWord, HttpServletRequest request) {
        boolean bool = shieldWordService.changeShieldWordService(shieldWord);
        request.setAttribute("data", shieldWord);
        request.setAttribute("bool", bool);
        return "/WEB-INF/admin/version/shieldWord";
    }

}
